/**
 * Created by LINLA5 on 8/25/2016.
 */
angular.module("order").controller("checkoutController", function ($scope, $routeParams, $http) {
    var mid = $routeParams.mid;
    //var mid = 123;
    var cid = '';
    $http.get('/order/merchant/' + mid)
        .then(function (res) {
            var data = res.data;
            if(data.msg == "ERROR"){
                window.location = "/login.html"
            }

            if (data.success == true) {
                $scope.currentOrderDetail = data.data;
                cid = data.data.client._id;
            }
        }, function (res) {
            console.error(res.data.msg);
        })

    $scope.confirm = function () {
        $http.put('/order/merchant/' + mid + '?action=2', {}).then(function(res){
            var data = res.data;
            if (data.success == true) {
                window.location = "#/order/waitAndRecieve";
            }
        })
    }
})